dojo.provide("uws.drawing.sqlerd.Entity");
dojo.require('uws.drawing.Component');

dojo.declare('uws.drawing.sqlerd.Entity',uws.drawing.Component,{
	constructor: function(surface,id,dx,dy, sortOrder,label,fromDS){
		this.center_x = 50;
        this.center_y = 15;
		this.sortOrder = sortOrder;
		
		if(fromDS){
			dx+=this.center_x;
			dy+=this.center_y;
		}
		
		//connectors
		this.top_con=this.connectors_shape_group.createCircle({
			cx: this.center_x,
			cy: 0,
			r:3
		}).setStroke("white").setFill("white");
		
		this.bottom_con=this.connectors_shape_group.createCircle({
			cx: this.center_x,
			cy: (this.center_y*2),
			r:3
		}).setStroke("white").setFill("white");
		
		this.left_con=this.connectors_shape_group.createCircle({
			cx: 0,
			cy: this.center_y,
			r:3
		}).setStroke("white").setFill("white");
		
		this.right_con=this.connectors_shape_group.createCircle({
			cx: (this.center_x*2),
			cy: this.center_y,
			r:3
		}).setStroke("white").setFill("white");
		
		//actual shape
		this.actual_shape_group.createRect({
			x:0,
			y:0,
			width:100,
			height:30
		}).setStroke("black").setFill("white");
		
		this.label_shape = this.actual_shape_group.createText({
			text: label,
			x:this.center_x,
			y:(this.center_y + 8),
			align:"middle"
		}).setFill("black").setFont(defaultFont);
		
		this._postCreate(dx, dy);
	},
	applyProperties:function(properties){
		this.label_shape.setShape({
			text: properties.label,
			x:this.center_x,
			y:(this.center_y),
			align:"middle"
		}).setFill("black").setFont(defaultFont);
	}
});